package com.dly.hope.workflow;

import com.dly.hope.modle.BaseEntity;
import com.dly.hope.workflow.type.ApprStatus;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.Date;

/**
* @Name: ProcessInstance
* @Description: 流程实例
* @Author: Danny Chen
* @Date: 2022/1/18
*/
@Entity
@Table(name = "wfl005_process_instance")
@Data
@DynamicInsert
@DynamicUpdate
public class ProcessInstance extends BaseEntity {

    @Id
    @GenericGenerator(name = "uuid", strategy = "org.hibernate.id.UUIDGenerator")
    @GeneratedValue(generator = "uuid")
    @Column(name = "id", nullable = false)
    private String id;

    /**
     * 流程定义ID
     */
    @Column(name = "process_id")
    private String processId;

    /**
     * 发起人ID
     */
    @Column(name = "sponsor_user_id")
    private String sponsorUserId;

    /**
     * 开始时间
     */
    @Column(name = "start_date")
    @Temporal(TemporalType.TIMESTAMP)
    @JsonFormat(pattern = "yyyy.MM.dd HH:mm:ss", timezone = "GMT+08:00")
    private Date startDate = new Date();

    /**
     * 过期时间
     */
    @Column(name = "expire_date")
    @Temporal(TemporalType.TIMESTAMP)
    @JsonFormat(pattern = "yyyy.MM.dd HH:mm:ss", timezone = "GMT+08:00")
    private Date expireDate;

    /**
     * 当前审批状态
     */
    @Column(name = "status")
    private Integer apprStatus = ApprStatus.NEW.getStatus();

    /**
     * 开始节点ID
     */
    @Column(name = "start_node_id")
    private String startNodeId;

    /**
     * 当前节点ID
     */
    @Column(name = "current_node_id")
    private String currentNodeId;

    /**
     * 当前实例显示序号
     */
    @Column(name = "current_display_no")
    private Integer currentDisplayNo = 0;

    /**
     * 对应表单ID
     */
    //@Column(name = "form_id")
    //private String formId;

    /**
     * 备注
     */
    @Column(name = "remark")
    private String remark;

}
